@import '../../../../styles-var/devui-var.scss';

$devui-tab-options-bg: $devui-brand-foil;
$devui-tab-slider-bg: $devui-list-item-hover-bg;

:host {
  display: block;
}

.#{$devui-prefix}-tabs__nav--tabs,
.#{$devui-prefix}-tabs__nav--pills {
  font-size: $devui-font-size;
  background: transparent;
  list-style: none;

  li {
    cursor: pointer;
    border: 2px solid transparent;

    & a {
      cursor: pointer;
      border: none;
      line-height: 30px;
      background-color: transparent;
      padding: 0;
      text-decoration: none;
      color: $devui-aide-text;
    }

    & a:hover,
    & a:focus,
    & a:active {
      outline: none;
    }

    &.disabled {
      a {
        color: $devui-disabled-text;
        cursor: not-allowed;
      }
    }

    &.active,
    &:hover:not(.disabled) {
      & a {
        color: $devui-brand;
      }
    }
  }

  li::after {
    content: '';
    display: block;
    margin: auto;
    height: 2px;
    width: 0;
    background: transparent;
    transition:
      width $devui-animation-duration-slow $devui-animation-ease-in-out,
      background-color $devui-animation-duration-slow $devui-animation-ease-in-out;
  }

  li.active::after {
    width: 100%;
    background: $devui-brand;
  }

  .#{$devui-prefix}-tabs__new-tab {
    padding: 2px 0 0;
  }
}

.#{$devui-prefix}-tabs__nav--options {
  background: $devui-base-bg;
  border: 1px solid $devui-dividing-line;
  border-radius: $devui-border-radius;
  padding: 2px;
  width: fit-content;

  & > li {
    cursor: pointer;
    background-color: $devui-base-bg;
    border-radius: $devui-border-radius;
    transition:
      background-color $devui-animation-duration-slow $devui-animation-ease-in-out,
      text-shadow $devui-animation-duration-slow $devui-animation-ease-in-out;

    & span > a {
      border: none;
      color: $devui-aide-text;
      line-height: 26px;
      padding: 0 16px;

      &:hover,
      &:focus,
      &:active {
        outline: none;
      }
    }

    &.active {
      background: $devui-global-bg;

      & span > a {
        color: $devui-brand;
        padding: 0 16px;
      }
    }

    &.disabled {
      border-color: $devui-disabled-line;

      a {
        color: $devui-disabled-text;
        cursor: not-allowed;
      }
    }

    &.active,
    &:hover:not(.disabled) {
      & span > a {
        &:hover {
          color: $devui-brand;
          background: transparent;
        }
      }
    }
  }
  .#{$devui-prefix}-tabs__close-btn {
    margin-right: 12px;
  }
  .#{$devui-prefix}-tabs__new-tab {
    padding: 2px 16px 0;
  }
}

.#{$devui-prefix}-tabs__nav--slider {
  font-size: $devui-font-size;
  border: none;
  border-radius: $devui-border-radius;
  background: $devui-tab-slider-bg;
  width: fit-content;
  display: flex;
  align-items: center;
  position: relative;

  > li {
    cursor: pointer;
    margin: 2px;
    position: relative;
    z-index: 1;

    &:first-child {
      border-left-width: 1px;
      border-radius: $devui-border-radius 0 0 $devui-border-radius;
    }

    &:last-child {
      border-radius: 0 $devui-border-radius $devui-border-radius 0;
    }

    & a {
      cursor: pointer;
      border: none;
      color: $devui-aide-text;
      line-height: 28px;
      padding: 0 16px;

      &:hover,
      &:focus,
      &:active {
        outline: none;
      }
    }

    &.disabled {
      border-color: $devui-disabled-line;

      a {
        color: $devui-disabled-text;
        cursor: not-allowed;
      }
    }

    &.active,
    &:hover:not(.disabled) {
      & a {
        color: $devui-brand-active;

        &:hover {
          color: $devui-brand-active;
          background: transparent;
        }
      }
    }

    &.active {
      text-shadow: 0 0 0.7px $devui-brand;
    }

    &:hover:not(.active):not(.disabled) {
      color: $devui-brand-active;
    }
  }

  .#{$devui-prefix}-tabs__close-btn {
    margin-right: 12px;
  }
  .#{$devui-prefix}-tabs__new-tab {
    padding: 2px 16px 0;
  }
}

.#{$devui-prefix}-tabs__nav--wrapped {
  font-size: $devui-font-size;
  background: transparent;
  border-bottom: 1px solid $devui-dividing-line;
  background-color: $devui-base-bg;

  > li {
    cursor: pointer;
    position: relative;
    padding: 8px 16px;

    & a {
      cursor: pointer;
      border: none;
      color: $devui-aide-text;
      border-radius: $devui-border-radius $devui-border-radius 0 0;

      &:hover,
      &:focus,
      &:active {
        outline: none;
      }
    }

    &.disabled {
      border-color: $devui-disabled-line;

      a {
        color: $devui-disabled-text;
        cursor: not-allowed;
      }
    }

    &.active {
      border: 1px solid $devui-dividing-line;
      background: $devui-global-bg;
      border-radius: $devui-border-radius $devui-border-radius 0 0;
      // 以下覆盖父元素的底部边框,解决多1px的边框造成的抖动
      margin: -1px;
      border-bottom-color: transparent;

      & a {
        color: $devui-brand-active;
      }
    }

    &:hover:not(.active):not(.disabled) {
      a {
        color: $devui-brand;
      }
    }
  }
}

.#{$devui-prefix}-tabs__nav--tabs {
  border-bottom: 1px $devui-line solid;

  li {
    margin-left: 32px;
    margin-bottom: -3px;

    &:first-child {
      margin-left: 0;
    }
  }
}

.#{$devui-prefix}-tabs__nav--pills {
  > li {
    margin-left: 32px;

    &:first-child {
      margin-left: 0;
    }
  }
}

.#{$devui-prefix}-tabs__nav {
  display: flex;
  align-items: center;
  list-style: none;
  padding-left: 0;
  overflow-y: hidden;
  overflow-x: scroll;
  user-select: none;
  // 隐藏滚动条
  scrollbar-width: none;
  -ms-overflow-style: none;

  &::-webkit-scrollbar {
    display: none;
  }

  li {
    a {
      text-decoration: none;

      &.custom-width {
        display: inline-block;
        padding: 0;
        text-align: center;
      }
    }
  }

  &--right,
  &--left {
    margin: 0;
    .#{$devui-prefix}-tabs__nav-slider-animation {
      transition:
        top $devui-animation-duration-slow $devui-animation-ease-in-out,
        height $devui-animation-duration-slow $devui-animation-ease-in-out;
    }
    .#{$devui-prefix}-tabs__new-tab {
      text-align: center;
    }
  }

  &--right {
    display: block;
    float: right;
    border-bottom: none;
    margin-left: 10px;

    > li {
      margin-left: 0;
      padding: 0 16px;
      position: relative;
    }

    > li::after {
      display: none;
    }

    > li::before {
      content: ' ';
      position: absolute;
      top: 0;
      left: -5px;
      margin: auto;
      height: 0;
      width: 2px;
      background: transparent;
      transition:
        height $devui-animation-duration-slow $devui-animation-ease-in-out,
        background-color $devui-animation-duration-slow $devui-animation-ease-in-out;
    }

    > li.active::before {
      height: 100%;
      background: $devui-brand;
    }
  }

  &--left {
    display: block;
    float: left;
    border-bottom: none;
    margin-right: 10px;

    > li {
      margin-left: 0;
      padding: 0 16px;
      position: relative;
    }

    > li::after {
      content: ' ';
      position: absolute;
      top: 0;
      right: -5px;
      margin: auto;
      height: 0;
      width: 2px;
      background: transparent;
      transition:
        height $devui-animation-duration-slow $devui-animation-ease-in-out,
        background-color $devui-animation-duration-slow $devui-animation-ease-in-out;
    }

    > li.active::after {
      height: 100%;
      width: 2px;
      background: $devui-brand;
    }
  }
}

.#{$devui-prefix}-tabs__nav-content {
  display: flex;
  align-items: center;
}

.#{$devui-prefix}-tabs__nav--options {
  padding-left: 2px;
}

.#{$devui-prefix}-tabs__nav-slider-animation {
  position: absolute;
  z-index: 0;
  background-color: $devui-base-bg;
  border-radius: $devui-border-radius;
  box-shadow: 0 2px 4px 0 $devui-light-shadow;
  top: 1px;
  height: 30px;
  transition:
    left $devui-animation-duration-slow $devui-animation-ease-in-out,
    width $devui-animation-duration-slow $devui-animation-ease-in-out;
}

.#{$devui-prefix}-tabs {
  &__new-tab,
  &__close-btn {
    .#{$devui-prefix}-icon__container {
      &:hover {
        color: $devui-text;
      }

      > i {
        transition: none;
      }
    }
  }

  &__new-tab {
    .#{$devui-prefix}-icon__container {
      color: $devui-aide-text;
    }
  }

  &__close-btn {
    .#{$devui-prefix}-icon__container {
      color: $devui-form-control-line;
    }

    margin-left: 12px;
  }

  &--right,
  &--left {
    .#{$devui-prefix}-tabs__nav--options,
    .#{$devui-prefix}-tabs__nav--wrapped {
      border-bottom: 1px solid $devui-dividing-line;

      > li::after {
        display: none;
      }

      > li::before {
        display: none;
      }
    }
    .#{$devui-prefix}-tabs__nav--wrapped {
      border-bottom: none;

      > li {
        padding: 8px 16px;
      }
    }
    .#{$devui-prefix}-tabs__nav--slider {
      > li::after {
        display: none;
      }

      > li::before {
        display: none;
      }
    }
    .#{$devui-prefix}-tabs__nav--slider {
      .#{$devui-prefix}-tabs__nav-slider-animation {
        left: 1px;
      }
    }
  }

  &--right {
    .#{$devui-prefix}-tabs__nav--wrapped {
      border-left: 1px solid $devui-dividing-line;

      > li {
        & a {
          border-radius: 0 $devui-border-radius $devui-border-radius 0;
        }

        &.active {
          border-radius: 0 $devui-border-radius $devui-border-radius 0;
          border-bottom-color: $devui-dividing-line;
          border-left-color: transparent;
        }
      }
    }

    .#{$devui-prefix}-tabs__nav--tabs {
      border-left: 1px solid $devui-line;
    }
  }

  &--left {
    .#{$devui-prefix}-tabs__nav--wrapped {
      border-right: 1px solid $devui-dividing-line;

      > li {
        & a {
          border-radius: $devui-border-radius 0 0 $devui-border-radius;
        }

        &.active {
          border-radius: $devui-border-radius 0 0 $devui-border-radius;
          border-bottom-color: $devui-dividing-line;
          border-right-color: transparent;
        }
      }
    }

    .#{$devui-prefix}-tabs__nav--tabs {
      border-right: 1px solid $devui-line;
    }
  }
}
